package com.tencent.v_tjuntian.androidimproveing;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Toast;

import com.tencent.v_tjuntian.iosviewlibrary.dialog.SweetAlertDialog;
import com.tencent.v_tjuntian.iosviewlibrary.popmenu.ActionSheetDialog;
import com.tencent.v_tjuntian.iosviewlibrary.popmenu.AlertDialog;
import com.tencent.v_tjuntian.iosviewlibrary.toast.T;
import com.tencent.v_tjuntian.iosviewlibrary.wheel.LoopView;
import com.tencent.v_tjuntian.iosviewlibrary.wheel.OnItemSelectedListener;

import java.util.ArrayList;

public class MainActivity extends AppCompatActivity {

    private Toast toast;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        final LoopView loopView = (LoopView) findViewById(R.id.loopView);

        ArrayList<String> list = new ArrayList<>();
        for (int i = 0; i < 15; i++) {
            list.add("item " + i);
        }
        //设置是否循环播放
//        loopView.setNotLoop();
        //滚动监听
        loopView.setListener(new OnItemSelectedListener() {
            @Override
            public void onItemSelected(int index) {
                if (toast == null) {
                    toast = Toast.makeText(MainActivity.this, "item " + index, Toast.LENGTH_SHORT);
                }
                toast.setText("item " + index);
                toast.show();
            }
        });
        //设置原始数据
        loopView.setItems(list);

        //设置初始位置
        loopView.setInitPosition(0);


    }


    public void Loading(View view) {
        SweetAlertDialog dialog=new SweetAlertDialog(this);
        dialog.setTitleText("正在加载");
        dialog.show();
    }


    public void BottomShow(View view) {
        new ActionSheetDialog(this)
                .builder()
                .setCancelable(false)
                .setCanceledOnTouchOutside(false)
                .addSheetItem("发送给好友", ActionSheetDialog.SheetItemColor.Blue,
                        new ActionSheetDialog.OnSheetItemClickListener() {
                            @Override
                            public void onClick(int which) {

                            }
                        })
                .addSheetItem("转载到空间相册", ActionSheetDialog.SheetItemColor.Blue,
                        new ActionSheetDialog.OnSheetItemClickListener() {
                            @Override
                            public void onClick(int which) {

                            }
                        })
                .addSheetItem("上传到群相册", ActionSheetDialog.SheetItemColor.Blue,
                        new ActionSheetDialog.OnSheetItemClickListener() {
                            @Override
                            public void onClick(int which) {

                            }
                        })
                .addSheetItem("保存到手机", ActionSheetDialog.SheetItemColor.Blue,
                        new ActionSheetDialog.OnSheetItemClickListener() {
                            @Override
                            public void onClick(int which) {

                            }
                        })
                .addSheetItem("收藏", ActionSheetDialog.SheetItemColor.Blue,
                        new ActionSheetDialog.OnSheetItemClickListener() {
                            @Override
                            public void onClick(int which) {

                            }
                        }).show();
    }

    public void CenterShow(View view) {
        new AlertDialog(this).builder().setTitle("退出当前账号")
                .setMsg("再连续登陆15天，就可变身为QQ达人。退出QQ可能会使你现有记录归零，确定退出？")
                .setPositiveButton("确认退出", new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {

                    }
                }).setNegativeButton("取消", new View.OnClickListener() {
            @Override
            public void onClick(View v) {

            }
        }).show();
    }

    public void CenterShow1(View view) {
        new AlertDialog(this).builder()
                .setMsg("你现在无法接收到新消息提醒。请到系统-设置-通知中开启消息提醒")
                .setNegativeButton("确定", new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {

                    }
                }).show();
    }

    public void BottomShow2(View view) {
        new ActionSheetDialog(this)
                .builder()
                .setTitle("清空消息列表后，聊天记录依然保留，确定要清空消息列表？")
                .setCancelable(false)
                .setCanceledOnTouchOutside(false)
                .addSheetItem("清空消息列表", ActionSheetDialog.SheetItemColor.Red
                        , new ActionSheetDialog.OnSheetItemClickListener() {
                            @Override
                            public void onClick(int which) {

                            }
                        }).show();
    }

    public void CenterSuccess(View view) {
        T.showAnimToast(MainActivity.this, "恭喜您，注册成功了！");
    }

    public void SaveSuccess(View view) {
        T.showAnimSuccessToast(MainActivity.this, "保存成功");
    }


    public void SaveFail(View view) {
        T.showAnimErrorToast(MainActivity.this, "修改失败");
    }
}
